|
|
|
|
|
|
|
Figure 7.12
Using PaintPicture to enlarge an image can make it appear blocky. |
|
|
|
|
|
|
|
|
If the unknown pixel is close to the first known pixel, it should have a value similar to that of the first pixel. |
|
|
|
|
|
|
|
|
Similarly, if you assume D2 is very small, you will find that V is close to V2. This also makes sense: If the unknown pixel is close to the second known pixel, it should have a value similar to that of the second pixel. |
|
|
|
|
|
|
|
|
Finally, if D1 = D2, the equation turns into the ordinary average of the values V1 and V2. If the unknown pixel lies exactly between the other two, its value should be the average of the values of the other two. |
|
|
|
|
|
|
|
|
Assigning an intermediate value proportionally to its distance from known values is called linear interpolation. The situation is slightly more complicated with images because images are two dimensional. Some of the unknown pixel values in the enlarged image do not lie exactly between two known pixels. |
|
|
|
|
|
|
|
|
Suppose you need to assign the value of a pixel at position (x0, y0) and you know the values of the four nearest pixels at positions (x1, y1), (x1, y2), (x2, y1), and (x2, y2) as shown in Figure 7.13. Then you can estimate the unknown pixel's value by using linear interpolation twice, once horizontally and once vertically. This is called bilinear interpolation. |
|
|
|
|
|
|
|
|
Figure 7.13
Finding a pixel's color using bilinear interpolation. |
|
|
|
|
|